package cn.hanyx.coder.design.pattern.behavioral.chain.demo03;


/**
 * Application
 *
 * @author hanyx
 * @date 2020/06/05
 */
public class Application {
    public void call(Message msg) {
        HandlerChain chain = new HandlerChain();
        chain.addHandler(new HandlerA());
        chain.addHandler(new HandlerB());
        chain.addHandler(new HandlerC());
        chain.handle(msg);
        System.out.println(msg);
    }

    public static void main(String[] args) {

        Runnable runnable = () -> {
            Application application = new Application();
            Message msg = new Message();
            msg.setMsg("chain");
            application.call(msg);
        };

        Thread thread = new Thread(runnable);
        thread.start();
        Thread thread1 = new Thread(runnable);
        thread1.start();

    }
}
